<!DOCTYPE html>
<html lang="en">

<head>
  <title>Getting Started with ml5.js</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script src="../common/tensorflow-0.9.0.js"></script>
</head>

<body>

  <script>
    //小鸟飞翔
    //创建一个空神经网络
    var model = tf.sequential()

    //小鸟飞翔输入层接受两个参数,管子的高度+小鸟的高度  inputShape: [2]
    //输出值有两个,跳/不跳                         units: 2
    model.add(tf.layers.dense({ inputShape: [2], units: 2, activat: 'softmax' }))

    //指定中间层参数
    var w1 = tf.tensor([-3.288, 5.791, 29.392, -13.817], [1, 4])  //1个参数,四个神经元
    var b1 = tf.tensor([-0.365, -1.031, -5.902, 3.069], [1, 4])
    model.layers[0].setWeights(w1, b1)


    var w2 = tf.tensor([-0.878, -0.704, -0.212, -0.517], [4, 1])  //4个参数,一个神经元
    var b2 = tf.tensor([-0.27], [1, 1])
    model.layers[1].setWeights(w2, b2)
    //正向传播
    function predict(x) {
      var input = tf.tensor(x, [1, 1])
      var output = model.predict(input)
      return output.dataSync()[0]
    }`
  </script>
</body>

</html>